//
//  RGUserInfoModel.m
//  RedGrass
//
//  Created by wukong on 2019/1/2.
//  Copyright © 2019年 hongcaosp. All rights reserved.
//

#import "RGUserInfoModel.h"

@implementation RGUserInfoModel

+(BOOL)propertyIsOptional:(NSString*)propertyName{
    return YES;
}

+ (JSONKeyMapper *)keyMapper{
    // 属性名作为key ,字典中的key名 作为 value
    return [[JSONKeyMapper alloc]initWithModelToJSONDictionary:@{@"ID":@"id"}];
}

+(void)storeUserInfo:(RGUserInfoModel *)user {
    if (user) {
        NSData *data = [NSKeyedArchiver archivedDataWithRootObject:user];
        [[NSUserDefaults standardUserDefaults] setObject:data forKey:@"userInfo"];
        [[NSUserDefaults standardUserDefaults]  synchronize];
    }
}

+(RGUserInfoModel *)getUserInfo {
    NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:@"userInfo"];
    if (data) {
        RGUserInfoModel *user = [NSKeyedUnarchiver unarchiveObjectWithData:data];
        return user;
    } else
        return nil;
}


@end
